<html>
<head><meta charset="utf-8"><title>Declarative macro repetition counts lang-team#28 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html">Declarative macro repetition counts lang-team#28</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201834413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/201834413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#201834413">(Jun 24 2020 at 11:01)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/28">#28</a>. It will be brought up at the next meeting.</p>



<a name="201897246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/201897246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#201897246">(Jun 24 2020 at 20:09)</a>:</h4>
<p>I am partial to the metafunction syntax (<code>${count(var, 2)}</code>), since it is probably the most extensible, and it doesn't conflict with the <code>quote!</code>macro's <code>#var</code> syntax.</p>



<a name="201897466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/201897466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#201897466">(Jun 24 2020 at 20:11)</a>:</h4>
<p>additionally, the metafunction syntax is less obtuse.</p>



<a name="202015163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202015163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202015163">(Jun 25 2020 at 19:38)</a>:</h4>
<p>I would say we shouldn't worry too much about the syntax at this stage and more think about the motivation, although it's good to collect some ideas.</p>



<a name="202015180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202015180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202015180">(Jun 25 2020 at 19:38)</a>:</h4>
<p>Anyway I think this seems like a pretty good idea... unlikely to be all that controversial.</p>



<a name="202015760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202015760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202015760">(Jun 25 2020 at 19:44)</a>:</h4>
<p>The question I guess is whether anyone has the time/energy to serve as a liaison. I'm not sure just how demanding that will be in this case. I'm feeling pretty hard up for time so I'm a bit reluctant to volunteer.</p>



<a name="202320643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202320643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202320643">(Jun 29 2020 at 14:48)</a>:</h4>
<p>I'm happy to do whatever leg-work is involved that I can help with.</p>



<a name="202357411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202357411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202357411">(Jun 29 2020 at 19:30)</a>:</h4>
<p><span class="user-mention" data-user-id="312456">@Mark Thomas</span> would you be interested in implementing the proposal as well?</p>



<a name="202357530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202357530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202357530">(Jun 29 2020 at 19:31)</a>:</h4>
<p>I posted this in the github issue but I'll put it here too: An earlier proposal that covers similar ground is <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a></p>



<a name="202357701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202357701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202357701">(Jun 29 2020 at 19:33)</a>:</h4>
<p>the main differences I could identify: 1. <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a> uses the syntax <code>$#(..)</code> instead of <code>$#ident</code></p>



<a name="202357741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202357741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202357741">(Jun 29 2020 at 19:33)</a>:</h4>
<p>(where the <code>..</code> is the token sequence used in the macro pattern)</p>



<a name="202358008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358008">(Jun 29 2020 at 19:36)</a>:</h4>
<p>(I don't think there is a strong reason to choose one syntax over another here. We could in fact adopt both. I do like <code>$#(..)</code> because I can directly see the correspondence between the thing in the pattern and the thing after the <code>$#</code>, but I could also believe that in practice macro authors would prefer to use <code>$#ident</code> to express this.)</p>



<a name="202358094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358094">(Jun 29 2020 at 19:36)</a>:</h4>
<p>difference 2. <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a> <em>also</em> proposes a syntax for getting the <strong>current iteration count</strong> in the expansion, i.e. its syntax <code>$(#)</code></p>



<a name="202358165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358165">(Jun 29 2020 at 19:37)</a>:</h4>
<p>That seems like a really important thing in practice, and it isn't addressed in the proposal  <a href="https://github.com/rust-lang/lang-team/issues/28">#28</a>, is it?</p>



<a name="202358292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358292">(Jun 29 2020 at 19:38)</a>:</h4>
<p>(unfortunately the RFC text for <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a> doesn't actually write out a motivating example for the current iteration number. <span aria-label="sad" class="emoji emoji-2639" role="img" title="sad">:sad:</span> )</p>



<a name="202358619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358619">(Jun 29 2020 at 19:40)</a>:</h4>
<p>I think my summary comment (from, yikes, six years ago) holds up well: <a href="https://github.com/rust-lang/rfcs/pull/88#issuecomment-47651303">https://github.com/rust-lang/rfcs/pull/88#issuecomment-47651303</a></p>



<a name="202358693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202358693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202358693">(Jun 29 2020 at 19:41)</a>:</h4>
<p>specifically, I expressed concern for the syntax <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a> chose for the iteration number (and I would still have that concern today).</p>



<a name="202359057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202359057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202359057">(Jun 29 2020 at 19:44)</a>:</h4>
<p>anyway there are a lot of other points made in that comment thread that probably apply here</p>



<a name="202369431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202369431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202369431">(Jun 29 2020 at 21:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328/near/202357411">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="312456">Mark Thomas</span> would you be interested in implementing the proposal as well?</p>
</blockquote>
<p>Yes, I'd be interested in implementing it.  I already have a working prototype of the simplest version (<code>$#ident</code> only).</p>



<a name="202370601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202370601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202370601">(Jun 29 2020 at 21:31)</a>:</h4>
<p>I had looked for other rfcs that covered this but somehow failed to find <a href="https://github.com/rust-lang/rfcs/issues/88">rfc#88</a>.  Thanks for the link!  The rfc proposal has some interesting ideas that I hadn't thought of: in particular getting the current index, which is something else that I've needed in the past (in <a href="https://github.com/dgrunwald/rust-cpython/blob/master/src/py_class/slots.rs#L789">https://github.com/dgrunwald/rust-cpython/blob/master/src/py_class/slots.rs#L789</a> for example).<br>
It sounds like there might be two things that one might want in different contexts: the count (potentially summed over nested repetitions) and the  index (potentially for outer nestings, not necessarily the current one).  A concern I had with the <code>$###ident</code> suggestion for the first one is that it's quickly becoming a soup of sigils that are harder to understand, and extending it for the index too would be difficult.<br>
What do people think of the <code>${ ... }</code> meta-expression syntax?  I think we could encompass all options with:</p>
<ul>
<li><code>${count(ident)}</code> for the count at the current nesting (and <code>${count(ident, n)}</code> for counting at repetition depth n).</li>
<li><code>${index(ident)}</code> for the index at the current nesting (and <code>${index(ident, n)}</code> for the index at repetition depth n).<br>
This is more complex than the simple <code>$#ident</code> proposal, but I think both could be implemented fairly easily.  If I get some time I will have a go at extending my prototype to include both of these.</li>
</ul>



<a name="202388554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202388554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202388554">(Jun 30 2020 at 02:12)</a>:</h4>
<p>I like the <code>${count(name)}</code> syntax both because is easily extendible to other expressions, and because it doesn't conflict with <code>quote!</code>'s syntax, which replaces all occurrences of <code>#ident</code> or <code>#(...)*</code></p>



<a name="202485516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202485516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202485516">(Jun 30 2020 at 19:46)</a>:</h4>
<p>Pretty much any new syntax on the right hand side of a macro will have backward compatibility issues, at least in theory, because the right hand side is an arbitrary token stream.</p>



<a name="202485628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202485628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202485628">(Jun 30 2020 at 19:47)</a>:</h4>
<p>I wonder if it's possible to find some syntax that always produces an error now. (I can't come up with anything right away.)</p>



<a name="202486486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202486486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202486486">(Jun 30 2020 at 19:54)</a>:</h4>
<p>Aha, <code>$ anything_that_is_not_ident</code> is actually reserved, that's a good news.</p>



<a name="202486707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/202486707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#202486707">(Jun 30 2020 at 19:56)</a>:</h4>
<p>(But I'm still interested to know what other options exist.)</p>



<a name="205267141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205267141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205267141">(Jul 28 2020 at 17:41)</a>:</h4>
<p><span class="user-mention" data-user-id="312456">@Mark Thomas</span> I take it you're the <code>markbt</code> from Github?</p>
<p>I've been selected as your T-Lang liaison! Hello.</p>
<p>The next step is to create a <strong>charter</strong> for the project group, and then PR it into the lang-team repo to officially found the group. The charter document needs to focus on:</p>
<ul>
<li>The <strong>problem statement</strong> that the project group is trying to solve.</li>
<li>The general scope of the project (eg: "We will develop an RFC for new macro syntax and then implement it").</li>
<li>The project lead (you).</li>
<li>Any other initial team members who wish to be listed (if any).</li>
<li>The project liaison (me).</li>
<li>Who will help implement the eventual RFC (you, i think you said).</li>
</ul>
<p>As with any PR, the lang team will review, possibly request changes, and so on.</p>
<p>Once the project group is officially accepted, you and whoever else will do all the discussion work necessary to draft a fully detailed RFC that will go through the usual RFC process. Since this is a relatively simple proposal, it's unlikely that any experimental work will need to be done in the compiler before the RFC is accepted. The idea is to do as much of the discussion on Zulip <em>before</em> actually opening a PR with the RFC proposal. Long discussions don't work well in a PR comment thread.</p>
<p>As your liaison, I'm your reprisentative to help keep T-lang updated on your progress. I can also help with editing on the RFC, but ultimately my role is more as a conduit for communication, and the project is still in your hands.</p>



<a name="205278763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205278763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205278763">(Jul 28 2020 at 19:20)</a>:</h4>
<p>One thing I would add is that I think the charter can be heavily copied from the existing MCP, although in this case I feel like there were some additional issues raised? i.e., it seems like there's a bit of exploration to be done to determine exactly which problems to solve</p>



<a name="205280205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205280205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205280205">(Jul 28 2020 at 19:32)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="224471">@Lokathor</span>,</p>
<p>Yes, I am <code>markbt</code> on Github.  That all sounds great.  <span class="user-mention" data-user-id="116009">@nikomatsakis</span> is right that the initial suggestion has grown into more general <code>${ ... }</code> syntax and covers both counts and indexes for repetitions.  I'll start from there in the next draft; we can always walk it back to the simpler syntax if that ends up looking like too much.</p>
<p>Is there a template or defined location for the charter?  I had a look in <a href="https://github.com/rust-lang/lang-team">https://github.com/rust-lang/lang-team</a> but couldn't see an obvious place to put it.  I should be able to work on a PR for that this weekend.</p>



<a name="205281295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205281295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205281295">(Jul 28 2020 at 19:42)</a>:</h4>
<p>there's an open PR in that repo with a proposed template to use, that's the best place to start</p>



<a name="205281345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205281345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205281345">(Jul 28 2020 at 19:42)</a>:</h4>
<p>the template situation will hopefully be sorted out by the weekend</p>



<a name="205281792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205281792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205281792">(Jul 28 2020 at 19:46)</a>:</h4>
<p>Yep, but the plan is for the template to basically be the same as MCPs, with the intent that sometimes an MCP can just be copied over directly</p>



<a name="205281808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205281808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205281808">(Jul 28 2020 at 19:47)</a>:</h4>
<p>PS very open to suggestions :P</p>



<a name="205402271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205402271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205402271">(Jul 29 2020 at 19:26)</a>:</h4>
<p>So I've seen this proposal once again and it reminded me about evolution of variadic generics in C++.</p>
<p>Original variadic generics in C++11 are pretty similar to our macro repetitions in the way how they are used in practice.<br>
You get a list, then you pattern match on it to chop off a few elements from the start or from the end, then you use recursion to do the same thing with the rest of the list.<br>
Then it turned out that</p>
<ul>
<li>recursion is systematically worse understood by people than iteration/indexing, template metaprogramming is considered an arcane art or at least an advanced task</li>
<li>processing a list with recursion and pattern matching is wordy</li>
<li>processing a list with recursion and pattern matching is heavy on compilation times because it creates a lot of instantiations (or a lot of expansions with Rust macros)</li>
</ul>
<p>As a result things started to moving in the direction of more direct operations with parameter packs - indexing into a pack, slicing into a pack (an operator for taking pack length was introduced immediately in C++11 though).<br>
The current iteration of the proposal is <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1858r2.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1858r2.html</a>.<br>
Clang introduced a builtin for pack indexing years ago already to fight the instantiation bloat and compile times.</p>
<p>So, I thought perhaps we should immediately jump to the end point of this process, get away from recursion, and introduce macro repetition indexing and slicing right away? <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span><br>
(With the length taking operator from this proposal as a necessary component.)</p>



<a name="205409225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205409225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205409225">(Jul 29 2020 at 20:25)</a>:</h4>
<p>baby steps</p>



<a name="205409729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205409729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205409729">(Jul 29 2020 at 20:29)</a>:</h4>
<p>To say a little more: I think that the <code>${ ... }</code> syntax can be added to in a lot of ways over time, but for now let's (1) found the project group at all (2) just let people count the repetitions to start.</p>
<p>As long as we pick a syntax that's broadly future compatible with later improvement, I think we should focus on actually shipping this one small improvement over starting up another grand design. We've already got inline assembly, const generics, async IO, and many other large projects in flight.</p>



<a name="205524683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205524683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205524683">(Jul 30 2020 at 19:55)</a>:</h4>
<p>I agree -- particularly since I think that the more advanced macros are moving to procedural macros.</p>



<a name="205524726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205524726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205524726">(Jul 30 2020 at 19:55)</a>:</h4>
<p>(I think it'd be quite appealing to do work towards making writing procedural macros easier and easier)</p>



<a name="205720141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205720141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205720141">(Aug 02 2020 at 09:41)</a>:</h4>
<p>I opened <a href="https://github.com/rust-lang/lang-team/pull/45">https://github.com/rust-lang/lang-team/pull/45</a> with a draft charter.</p>



<a name="205816968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Declarative%20macro%20repetition%20counts%20lang-team%2328/near/205816968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Declarative.20macro.20repetition.20counts.20lang-team.2328.html#205816968">(Aug 03 2020 at 16:40)</a>:</h4>
<p>awesome</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>